package ac.github.os.internal.core.config

import ac.github.os.internal.core.config.type.*
import ac.github.os.internal.session.Session
import org.bukkit.Location
import org.bukkit.Sound
import taboolib.common.platform.ProxyParticle
import taboolib.library.xseries.XPotion

interface DataType<T> {

    companion object {

        val types = mutableMapOf<Class<*>, DataType<*>>()

        init {
            types[Boolean::class.java] = DataBoolean()
            types[Double::class.java] = DataDouble()
            types[Int::class.java] = DataInt()
            types[String::class.java] = DataString()
            types[List::class.java] = DataArray()
            types[Float::class.java] = DataFloat()
            types[Sound::class.java] = DataSound()
            types[Location::class.java] = DataLocation()
            types[ProxyParticle::class.java] = DataParticle()
            types[XPotion::class.java] = DataPotion()
            types[Long::class.java] = DataLong()
        }

        fun cover(clazz: Class<*>): Class<*> {
            return when (clazz.name) {
                "java.lang.String" -> String::class.java
                "java.lang.Double" -> Double::class.java
                "java.lang.Integer" -> Int::class.java
                "java.lang.Float" -> Float::class.java
                "java.lang.Boolean" -> Boolean::class.java
                "java.lang.Long" -> Long::class.java
                else -> clazz
            }
        }

    }


    fun toValue(string: String, session: Session): T?

}